package com.alog.common.code;

import java.util.ArrayList;

public class Queue {
    private ArrayList<String> arr = new ArrayList<>();
    private int count = 0;
    private static volatile Queue instance;
    private static Object obj = new Object();
    private Queue(){}

    public static Queue getInstance(){
        if(instance == null){
            synchronized (obj){
                if(instance == null){
                    instance = new Queue();
                }
            }
        }
        return instance;
    }

    public int size(){
        return arr.size();
    }

    public void add(){
        arr.add((count++) + "");
    }

    public String poll(){
        return arr.remove(0);
    }

    public String get(){
        return arr.get(0);
    }
}
